import request from "@/utils/request";

/**
 * 获取订单交易页信息
 * @returns 订单交易页信息
 */
export const reqGetTradeInfo = () => {
  return request({
    method: "GET",
    url: "/order/auth/trade",
  });
};

/**
 * 提交订单
 * @param {*} 订单参数
 * @returns
 */
export const reqSubmitOrder = ({ tradeNo, ...data }) => {
  return request({
    method: "POST",
    url: "/order/auth/submitOrder",
    data,
    params: {
      tradeNo,
    },
  });
};

/**
 * 获取支付二维码
 * @param {number} orderId 订单id
 * @returns 支付二维码
 */
export const reqGetPayQRCode = (orderId) => {
  return request({
    method: "GET",
    url: `/payment/weixin/createNative/${orderId}`,
  });
};

/**
 * 查询订单支付状态
 * @param {number} orderId 订单id
 * @returns
 */
export const reqQueryPayStatus = (orderId) => {
  return request({
    method: "GET",
    url: `/payment/weixin/queryPayStatus/${orderId}`,
  });
};

/**
 * 获取订单列表
 * @param {number} page 当前页码
 * @param {number} limit 每页条数
 * @returns 订单列表
 */
export const reqGetOrderList = (page, limit) => {
  return request({
    method: "GET",
    url: `/order/auth/${page}/${limit}`,
  });
};
